<template>
  <FormBlock title="参保人">
    <template #right>
      <!-- <div
      class="insuredInfo-autoPerson"
      @click="$emit('getPervPerson')"
    >
      填入去年参保人信息
    </div> -->
    </template>

    <div
      v-for="(insuredInfo, index) in insuredInfoListTempData"
      :key="insuredInfo.key"
    >
      <InsuredInfoItem 
      :insuredInfo="insuredInfo"
      :index="index+1"
      :ref="`InsuredInfoItemRef${index}`"
        />
    </div>
    <van-button
     style="marginTop:10px"
      plain
      size="large"
      @click="$emit('addInsuredInfo')"
    >
      新增参保人
    </van-button>
  </FormBlock>
</template>

<script>
import FormBlock from "./form/FormBlock";
import InsuredInfoItem from "./InsuredInfoItem";
export default {
  components: {
    FormBlock,
    InsuredInfoItem,
  },
  props: {
    insuredInfoListTempData: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    async validate() {
      for (const index in this.insuredInfoListTempData) {
        await this.$refs[`InsuredInfoItemRef${index}`][0].validate()
      }
    }
  },
};
</script>

<style scoped lang="less">
</style>
